package me.firstapp.module.shop;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import me.firstapp.module.base.CommonEntity;
import me.firstapp.module.bbs.Member;

@Entity
@Table(name = "SHOP_ORDER")
public class Order extends CommonEntity {

	private static final long serialVersionUID = 7133927829769462608L;

	// 订单号
	@Column(name = "ORDER_NO", length = 50, unique = true, nullable = false)
	private String orderNo;

	// 关联的用户
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MEMBER_ID", referencedColumnName = "ID", nullable = false)
	private Member member;

	// 订单状态0,未支付(未支付);1,待发货(已支付);2,待收货(已发货);3,已完成;4,已取消;5,退款/售后;
	@Column(name = "STATUS", columnDefinition = "TINYINT", nullable = false)
	private Integer status;

	// 商品总数量
	@Column(name = "COUNTS", nullable = false)
	private Integer counts;

	// 商品总金额
	@Column(name = "VALUE", columnDefinition = "DECIMAL(11, 2)", nullable = false)
	private Double value;

	// 快递名称
	@Column(name = "EXPRESS_NAME", length = 20)
	private String expressName;

	// 快递单号
	@Column(name = "EXPRESS_NO", length = 100)
	private String expressNo;

	// 收货人
	@Column(name = "RECEIVE_NAME", length = 20, nullable = false)
	private String receiveName;

	// 收货地址
	@Column(name = "RECEIVE_ADDRESS", length = 300, nullable = false)
	private String receiveAddress;

	// 订单创建时间
	@Column(name = "CREATE_TIME", columnDefinition = "DATETIME", nullable = false)
	private Date createTime;

	// 发货时间
	@Column(name = "DISTRIBUTE_TIME", columnDefinition = "DATETIME", nullable = true)
	private Date distributeTime;

	// 备注
	@Column(name = "REMARK", length = 150)
	private String remark;

	@Transient
	private List<OrderItem> items = new ArrayList<>();

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getCounts() {
		return counts;
	}

	public void setCounts(Integer counts) {
		this.counts = counts;
	}

	public Double getValue() {
		return value;
	}

	public void setValue(Double value) {
		this.value = value;
	}

	public List<OrderItem> getItems() {
		return items;
	}

	public void setItems(List<OrderItem> items) {
		this.items = items;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getExpressName() {
		return expressName;
	}

	public void setExpressName(String expressName) {
		this.expressName = expressName;
	}

	public String getExpressNo() {
		return expressNo;
	}

	public void setExpressNo(String expressNo) {
		this.expressNo = expressNo;
	}

	public String getReceiveName() {
		return receiveName;
	}

	public void setReceiveName(String receiveName) {
		this.receiveName = receiveName;
	}

	public String getReceiveAddress() {
		return receiveAddress;
	}

	public void setReceiveAddress(String receiveAddress) {
		this.receiveAddress = receiveAddress;
	}

	public Date getDistributeTime() {
		return distributeTime;
	}

	public void setDistributeTime(Date distributeTime) {
		this.distributeTime = distributeTime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
